<script>
	import API from '@/common/api.js';
	export default {
		globalData: {
			baseinfo: [],
			minappinfo:[],
		},
		onLaunch: function() {
			console.log('App Launch');
			//uni.hideTabBar();
		},
		onShow: function() {
			if (uni.getStorageSync('baseinfo')) {
				this.globalData.baseinfo = uni.getStorageSync('baseinfo');
			}else{
				API.getBaseInfo().then(res => {
						this.globalData.baseinfo = res.data;
						uni.setStorageSync('baseinfo', res.data);
					})
					.catch(err => {
						console.log(err)
					})
			}
			if (uni.getStorageSync('minappinfo')) {
				this.globalData.minappinfo = uni.getStorageSync('minappinfo');
			}else{
				API.getMinappInfo().then(res => {
						let tmp = res.data.data; 
						if(res.data.data.tLogo){
							tmp.tLogo = API.getApiUrl() + '/cos/img?key=' + res.data.data.tLogo;
						}
						if(res.data.data.tTopBg){
							tmp.tTopBg = API.getApiUrl() + '/cos/img?key=' + res.data.data.tTopBg;
						}
						this.globalData.minappinfo = tmp;
						uni.setStorageSync('minappinfo', tmp);
					})
					.catch(err => {
						console.log(err)
					})
			}
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "uview-ui/index.scss";
	.u-tabs{
		background-color: #ffffff;
	}
</style>
